<template>
	<view class='page_cont'>
		<teacherItem :teachers="teachers" :status="6"></teacherItem>
		<view class='no_cont' v-if="show_nav">
			<view class="no_box">
			    <view class='title'>暂时还没有服务推送记录哦</view>
			</view>
			<view class='nav_btn' @click="nav_home">去首页</view>
		</view>
	</view>
</template>

<script>
	import myResume from "../../api/myResume.js"
	import util from "../../utils/util.js"
	import TeacherItem from "../../components/teacherItem.vue"
	export default{
		components: {
			teacherItem: TeacherItem
		},
		data(){
			return {
				teachers: [],
				queryList:{
					businessId: null,
					currentPage:1,
					pageSize:10
				},
				total:0,
				show_nav: false
			}
		},
		onLoad(options) {
			var that=this;
			that.queryList.businessId=options.id
		},
		onShow(){
			this.teachers=[]
			this.show_nav=false
			this.queryList.currentPage=1
			this.getList()
		},
		onReachBottom(){
			if(this.teachers.length<this.total){
				this.queryList.currentPage++
				this.getList()
			}else{
				util.page_show_toast('没有更多了',1500)
			}
		},
		methods:{
			// 回首页
			nav_home(){
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			getList(){
				uni.showLoading({})
				myResume.get_service_list(this.queryList).then(res=>{
					uni.hideLoading()
					res.data.data.records.forEach((item)=>{
						item.age=item.birthday?new Date().getFullYear()-new Date(item.birthday).getFullYear():''
						item.workYear=item.joinWorkTime?new Date().getFullYear()-new Date(item.joinWorkTime).getFullYear():''
						item.salary = item.salaryMin==0||!item.salaryMin?"面议":`${item.salaryMin/1000}-${item.salaryMax/1000}k/月`
						item.start=item.start?util.formatTime1(new Date(item.entryTime),1):'2020-1'
						item.end=item.end?util.formatTime1(new Date(item.quitTime),1):'2020-10'
						item.maxIndex=0
						item.works=[{start:item.start,end:item.end,businessName:item.businessName,positionName:item.positionInfoName}]
						item.reverseStatus=item.status
					})
					const {total,records} = res.data.data
					this.teachers.push(...records)
					this.total = total
					if(total==0){
						this.show_nav=true
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	page{
		background: #F6F7F9;
		.page_cont{
			width: 100%;
			.no_cont{
				width: 520rpx;
				margin: 110rpx auto 0 auto;
				.no_box{
					width: 100%;
					height: 520rpx;
					box-sizing: border-box;
					padding-top: 386rpx;
					background: url("https://ossdev0.jiabala.com/7XyPjGSZsyaek") no-repeat 0 0/100% 100%;
					.title{
						text-align: center;
						height: 50rpx;
						font-size: 32rpx;
						font-weight:400;
						line-height: 50rpx;
						color: #3F4A58;	
					}
					.text{
						margin-top: 8rpx;
						text-align: center;
						height: 40rpx;
						font-size: 28rpx;
						font-weight:400;
						line-height: 40rpx;
						color: #798594;
					}
				}
				.nav_btn{
					width: 272rpx;
					margin: auto;
					height: 88rpx;
					background: #5B90FF;
					text-align: center;
					font-size: 30rpx;
					font-weight: 400;
					line-height: 88rpx;
					color:#fff;
					letter-spacing:2rpx;
					border-radius: 16rpx;
				}
			}
		}
	}
</style>
